package com.example;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;

import android.annotation.SuppressLint;
import android.content.Context;
import android.telephony.TelephonyManager;
import android.util.Base64;

import com.example.singletones.contextObj;

@SuppressLint({ "NewApi", "NewApi" })
public class UserConfig {
	private String IMEI = null;
	private String mPhoneNumber = null;

	public String getIMEI() {
		if (IMEI == null) {
			Context myContext = contextObj.getInstance().getmContext();
			TelephonyManager tm = (TelephonyManager) (myContext
					.getSystemService(Context.TELEPHONY_SERVICE));
			MessageDigest mdb = null;
			try {
				mdb = MessageDigest.getInstance("SHA-512", "BC");
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (NoSuchProviderException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			byte[] digestb = mdb.digest(tm.getDeviceId().getBytes());
			IMEI = Base64.encodeToString(digestb, Base64.DEFAULT);
		}
		return IMEI;
	}

	public UserConfig() {

	}

	public String getmPhoneNumber() {
		if (mPhoneNumber == null) {
			Context myContext = contextObj.getInstance().getmContext();
			TelephonyManager tm = (TelephonyManager) (myContext
					.getSystemService(Context.TELEPHONY_SERVICE));
			MessageDigest mda = null;
			try {
				mda = MessageDigest.getInstance("SHA-512", "BC");
			} catch (NoSuchAlgorithmException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (NoSuchProviderException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			byte[] digesta = mda.digest(tm.getDeviceId().getBytes());
			mPhoneNumber = Base64.encodeToString(digesta, Base64.DEFAULT);
		}
		return mPhoneNumber;
	}
}
